import { User } from 'src/modules/user/entities/user.entity';
import {
  Column,
  Entity,
  JoinColumn,
  ManyToOne,
  PrimaryGeneratedColumn,
} from 'typeorm';
import { Event } from 'src/modules/event/entities/event.entity';
// import { Team } from 'src/modules/team/entities/team.entity';
import { EventTypeEnum } from 'src/common/constant/enums';
import { PlayerSignup } from 'src/modules/player-signup/entities/player-signup.entity';

@Entity('event_player')
export class EventToPlayer {
  @PrimaryGeneratedColumn()
  id?: number;

  @Column({ name: 'eventId' })
  eventId?: number;

  @ManyToOne(() => Event, (event) => event.eventToPlayers)
  @JoinColumn({ name: 'eventId' })
  event?: Event;

  @ManyToOne(() => PlayerSignup)
  @JoinColumn({ name: 'playerId' })
  player?: Partial<PlayerSignup>;

  @ManyToOne(() => PlayerSignup)
  @JoinColumn({ name: 'player2Id' })
  player2?: Partial<PlayerSignup>;

  @Column()
  registrationIndex: string; // e2p 在stage 中的唯一标识

  // @ManyToOne(() => Team, {
  //   cascade: true,
  // })
  // @JoinColumn({ name: 'teamId' })
  // team?: Partial<Team>;

  @Column({ name: 'subTemMatchType' })
  subTeamMatchType?: EventTypeEnum;

  @Column({ name: 'player1Name' })
  player1Name?: string;
  @Column({ name: 'player2Name' })
  player2Name?: string;
  @Column({ name: 'teamName' })
  teamName?: string;

  @Column({ name: 'playerId' })
  player1Id?: number;
  @Column({ name: 'player2Id' })
  player2Id?: number;

  @Column()
  stageOrderInEvent: number;

  @Column()
  isByePlayer: boolean; // 是否轮空

  @Column({ name: 'copyFromId' })
  copyFromId: number; // 复制自原记录ID
}
